import 'dart:convert';
import 'package:ichinesereader/models/book/MaxScore.dart';

BookQuizResult bookQuizResultFromJson(String str) =>
    BookQuizResult.fromJson(json.decode(str));
String bookQuizResultToJson(BookQuizResult data) => json.encode(data.toJson());

class BookQuizResult {
  BookQuizResult({
    this.levelProgress,
    this.maxScore,
    this.points,
    this.percentage,
    this.results,
    this.score,
    this.pass,
    this.message,
  });

  bool? levelProgress;
  MaxScore? maxScore;
  int? points;
  int? percentage;
  Map<String, bool>? results;
  int? score;
  bool? pass;
  String? message;

  factory BookQuizResult.fromJson(Map<String, dynamic> json) => BookQuizResult(
        levelProgress: json["levelProgress"],
        maxScore: MaxScore.fromJson(json["maxScore"]),
        points: json["points"],
        percentage: json["percentage"],
        results: Map.from(json["results"])
            .map((k, v) => MapEntry<String, bool>(k, v)),
        score: json["score"],
        pass: json["pass"],
        message: json["message"],
      );

  Map<String, dynamic> toJson() => {
        "levelProgress": levelProgress,
        "maxScore": maxScore?.toJson(),
        "points": points,
        "percentage": percentage,
        "results":
            Map.from(results!).map((k, v) => MapEntry<String, dynamic>(k, v)),
        "score": score,
        "pass": pass,
        "message": message,
      };
}

class Results {
  Results({
    this.number,
    this.grade,
  });

  int? number;
  bool? grade;
}
